/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 1.3.0.1</a>, using an XML
 * Schema.
 * $Id$
 */

package it.sd.wdc.schema.spider;

/**
 * Class Step.
 * 
 * @version $Revision$ $Date$
 */
@SuppressWarnings("serial")
public class Step extends it.sd.wdc.schema.spider.Bean 
implements java.io.Serializable
{


      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field _host.
     */
    private java.lang.String _host;

    /**
     * Field _method.
     */
    private java.lang.String _method;

    /**
     * Field _action.
     */
    private java.lang.String _action;

    /**
     * Field _protocol.
     */
    private java.lang.String _protocol;

    /**
     * Field _template.
     */
    private java.lang.String _template;

    /**
     * Field _resultList.
     */
    private java.util.List<it.sd.wdc.schema.spider.Result> _resultList;


      //----------------/
     //- Constructors -/
    //----------------/

    public Step() {
        super();
        this._resultList = new java.util.ArrayList<it.sd.wdc.schema.spider.Result>();
    }


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * 
     * 
     * @param vResult
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addResult(
            final it.sd.wdc.schema.spider.Result vResult)
    throws java.lang.IndexOutOfBoundsException {
        this._resultList.add(vResult);
    }

    /**
     * 
     * 
     * @param index
     * @param vResult
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addResult(
            final int index,
            final it.sd.wdc.schema.spider.Result vResult)
    throws java.lang.IndexOutOfBoundsException {
        this._resultList.add(index, vResult);
    }

    /**
     * Method enumerateResult.
     * 
     * @return an Enumeration over all possible elements of this
     * collection
     */
    public java.util.Enumeration<? extends it.sd.wdc.schema.spider.Result> enumerateResult(
    ) {
        return java.util.Collections.enumeration(this._resultList);
    }

    /**
     * Returns the value of field 'action'.
     * 
     * @return the value of field 'Action'.
     */
    public java.lang.String getAction(
    ) {
        return this._action;
    }

    /**
     * Returns the value of field 'host'.
     * 
     * @return the value of field 'Host'.
     */
    public java.lang.String getHost(
    ) {
        return this._host;
    }

    /**
     * Returns the value of field 'method'.
     * 
     * @return the value of field 'Method'.
     */
    public java.lang.String getMethod(
    ) {
        return this._method;
    }

    /**
     * Returns the value of field 'protocol'.
     * 
     * @return the value of field 'Protocol'.
     */
    public java.lang.String getProtocol(
    ) {
        return this._protocol;
    }

    /**
     * Method getResult.
     * 
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     * @return the value of the it.sd.wdc.schema.spider.Result at
     * the given index
     */
    public it.sd.wdc.schema.spider.Result getResult(
            final int index)
    throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._resultList.size()) {
            throw new IndexOutOfBoundsException("getResult: Index value '" + index + "' not in range [0.." + (this._resultList.size() - 1) + "]");
        }

        return (it.sd.wdc.schema.spider.Result) _resultList.get(index);
    }

    /**
     * Method getResult.Returns the contents of the collection in
     * an Array.  <p>Note:  Just in case the collection contents
     * are changing in another thread, we pass a 0-length Array of
     * the correct type into the API call.  This way we <i>know</i>
     * that the Array returned is of exactly the correct length.
     * 
     * @return this collection as an Array
     */
    public it.sd.wdc.schema.spider.Result[] getResult(
    ) {
        it.sd.wdc.schema.spider.Result[] array = new it.sd.wdc.schema.spider.Result[0];
        return (it.sd.wdc.schema.spider.Result[]) this._resultList.toArray(array);
    }

    /**
     * Method getResultCount.
     * 
     * @return the size of this collection
     */
    public int getResultCount(
    ) {
        return this._resultList.size();
    }

    /**
     * Returns the value of field 'template'.
     * 
     * @return the value of field 'Template'.
     */
    public java.lang.String getTemplate(
    ) {
        return this._template;
    }

    /**
     * Method isValid.
     * 
     * @return true if this object is valid according to the schema
     */
    public boolean isValid(
    ) {
        try {
            validate();
        } catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    }

    /**
     * Method iterateResult.
     * 
     * @return an Iterator over all possible elements in this
     * collection
     */
    public java.util.Iterator<? extends it.sd.wdc.schema.spider.Result> iterateResult(
    ) {
        return this._resultList.iterator();
    }

    /**
     * 
     * 
     * @param out
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     */
    public void marshal(
            final java.io.Writer out)
    throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Marshaller.marshal(this, out);
    }

    /**
     * 
     * 
     * @param handler
     * @throws java.io.IOException if an IOException occurs during
     * marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     */
    public void marshal(
            final org.xml.sax.ContentHandler handler)
    throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Marshaller.marshal(this, handler);
    }

    /**
     */
    public void removeAllResult(
    ) {
        this._resultList.clear();
    }

    /**
     * Method removeResult.
     * 
     * @param vResult
     * @return true if the object was removed from the collection.
     */
    public boolean removeResult(
            final it.sd.wdc.schema.spider.Result vResult) {
        boolean removed = _resultList.remove(vResult);
        return removed;
    }

    /**
     * Method removeResultAt.
     * 
     * @param index
     * @return the element removed from the collection
     */
    public it.sd.wdc.schema.spider.Result removeResultAt(
            final int index) {
        java.lang.Object obj = this._resultList.remove(index);
        return (it.sd.wdc.schema.spider.Result) obj;
    }

    /**
     * Sets the value of field 'action'.
     * 
     * @param action the value of field 'action'.
     */
    public void setAction(
            final java.lang.String action) {
        this._action = action;
    }

    /**
     * Sets the value of field 'host'.
     * 
     * @param host the value of field 'host'.
     */
    public void setHost(
            final java.lang.String host) {
        this._host = host;
    }

    /**
     * Sets the value of field 'method'.
     * 
     * @param method the value of field 'method'.
     */
    public void setMethod(
            final java.lang.String method) {
        this._method = method;
    }

    /**
     * Sets the value of field 'protocol'.
     * 
     * @param protocol the value of field 'protocol'.
     */
    public void setProtocol(
            final java.lang.String protocol) {
        this._protocol = protocol;
    }

    /**
     * 
     * 
     * @param index
     * @param vResult
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void setResult(
            final int index,
            final it.sd.wdc.schema.spider.Result vResult)
    throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._resultList.size()) {
            throw new IndexOutOfBoundsException("setResult: Index value '" + index + "' not in range [0.." + (this._resultList.size() - 1) + "]");
        }

        this._resultList.set(index, vResult);
    }

    /**
     * 
     * 
     * @param vResultArray
     */
    public void setResult(
            final it.sd.wdc.schema.spider.Result[] vResultArray) {
        //-- copy array
        _resultList.clear();

        for (int i = 0; i < vResultArray.length; i++) {
                this._resultList.add(vResultArray[i]);
        }
    }

    /**
     * Sets the value of field 'template'.
     * 
     * @param template the value of field 'template'.
     */
    public void setTemplate(
            final java.lang.String template) {
        this._template = template;
    }

    /**
     * Method unmarshal.
     * 
     * @param reader
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     * @return the unmarshaled it.sd.wdc.schema.spider.Step
     */
    public static it.sd.wdc.schema.spider.Step unmarshal(
            final java.io.Reader reader)
    throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        return (it.sd.wdc.schema.spider.Step) org.exolab.castor.xml.Unmarshaller.unmarshal(it.sd.wdc.schema.spider.Step.class, reader);
    }

    /**
     * 
     * 
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     */
    public void validate(
    )
    throws org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
        validator.validate(this);
    }

}
